<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>详情页</title>
</head>
<body>
    详情页


    <script>
        let params=new URLSearchParams(location.search)
        console.log(params);
        // params.size看有几个参数
        console.log(params.get('id'));
        console.log(params.get('price'));
        
        // 用地址截取获取参数
        console.log(location.href);
        // split("")以某个分隔符为界，把字符串转为数组 
        console.log(location.href.split('?'));
        var arr1=location.href.split('?')
        var arr2=arr1[1].split('&')
        console.log(arr2);

        // 转成对象
        var obj={}
        for (let i = 0; i < arr2.length; i++) {
            var arr3=arr2[i].split('=')
            console.log(arr3);
            
            obj[arr3[0]]=arr3[1]
            // [括号里是属性名]   
        }
        console.log(obj);

        // var stu={}
        // // 对象的两种设置属性方式
        // stu.name='张三';
        // stu['age']=18;
        // console.log(stu);
        

        
        
        
        


        
        
        

    </script>
</body>
</html>